<template>
	<view class="full-screen">
		<view class="round">

		</view>
		<image src="/static/png/register.png" mode="widthFix" style="width: 100%; height: 100%;"></image>
		<view class="butC">
			<view class="but" @click="gotoHome">
				Home
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getOpenId,doRegister,doLogin
	} from '@/api/register.js'
	export default {
		data() {
			return {

			};
		},
		onReady() {
			wx.login({
				success(res) {
					if (res.code) {
							uni.getUserInfo({
								success: info => {
									
						console.log(info.userInfo,'[[[]]]');
						//发起网络请求
						getOpenId(res.code).then(res => {
							doRegister(
							{
							    userName:info.userInfo.nickName,
							    openId: res.msg,
							    avatar:info.userInfo.avatarUrl
							}
							).then(loginVO=>{
							 doLogin({  "openId": loginVO.data.openId}).then(login=>{
										
								 uni.setStorageSync('token',login.token)
							
							 })
							 
							})
											
						
						})
								}
							})

					} else {
						console.log('登录失败！' + res.errMsg)
					}
				}
			})
		},
		methods: {
			gotoHome() {				
				//在起始页面跳转到test.vue页面并传递参数
				uni.switchTab({
					url: '/pages/record/record'
				});

			},
			
			
		}
	}
</script>

<style lang="less">
	.full-screen {
		width: 100%;
		height: 100vh;
		/* 使用视口高度 */
		overflow: hidden;
		/* 隐藏溢出内容 */
	}

	.round {
		position: absolute;
		right: -3%;
		width: 40rpx;
		height: 40rpx;
		background: #eabcffc7;
		border-radius: 50%;
		top: 4%;

	}

	.image-container {
		width: 100%;
		/* 图片容器宽度占满 */
		height: 100%;
		/* 图片容器高度占满 */
	}

	.butC {
		width: 100%;
		position: absolute;
		bottom: 10%;
		left: 5%;
		text-align: center;
		line-height: 6vh;
		font-size: 40rpx;
		color: #fff;
		font-weight: 200;

		.but {
			width: 40%;
			background: #eabcff;
			height: 6vh;
			border-radius: 70rpx;
		}
	}
</style>